//! Header for the SingletonBase class
/*!
	\file SingletonBase.h
	\author Thomas Pfeiffer
	\date 13.11.2012

*/
#ifndef SINGLETON_BASE_H
#define SINGLETON_BASE_H

#include "Object.h"

//! Base class to implement the singleton pattern
/*!
SingletonBase is a template Based class which implements the method getInstance()
for the derived classes and also prevents the user from copying or assigning
Singleton classes.
*/
template <typename TType>
class SingletonBase : public Object{
public:

	//! Returns an Instance of the class TType
	/*!
	The Function getInstance() returns an object of type TType. This function
	is the only way to get an instance of a class extending the class SingletonBase
	*/
	static TType& getInstance() {
		//declared in static method,
		//else linker error
		static TType oInstance;

		return oInstance ;	
	}

protected:
	//! Constructor of Singletonbase.
	/*!
	hide the constructor so that no object
	can be created except with getInstance()
	*/
	SingletonBase() {}

private:
	SingletonBase(SingletonBase const& s) {};
	SingletonBase& operator= (SingletonBase const& s) {};
};

#endif
